# a = 100
# print(a,"你好，Python!")
# print('a',"你好，Python!")
# print(chr(97))
# print(ord('北'))
# print(ord('a'))
# print('"你好"')
# Number = eval(input("请输入学号:>"))
# Class = input("请输入班级:>")
# Name = input("请输入名字:>")
# Height = float(input("请输入身高:>"))
# QQ = eval(input("请输入QQ:>"))
# print("QQ",QQ)
# print("学号:%d\n班级:%s\n姓名:%s\n身高:%.2f"%(Number,Class,Name,Height))
# import math
# print(math.sqrt(25))
# import random
# print(random.randrange(0,50,10))#3的倍数+右边界
# import numpy as np
# print(np.array((1,2,3,4)))
# from random import sample
# sample(range(100),10)#在指定范围内选择10个不同的元素
# b = 10
# a = 20
# if a>b:
#     max = a
#     print("%d"%max)
# a = r"abcd\n"#字符串前有r或者R转义字符将被忽略
# print("%s"%a)
# a = 10
# b = -20
# print(a&b)
# #8位二进制
# #00001010,10,a
# #11101100,-20,b
# #00001000,8,a&b
# print(a^b)
# """
# 11100110,a^b,10011010,-26
# """
# print(a<<2)
# #00101000,2*2*a,40
# print(b>>3)
# #11111101,10000011,-33
# import math
# r = float(input("请输入圆锥底面半径r:>"))
# h = float(input("请输入圆锥高:>"))
# if r>0 and h>0:
#     print("圆锥表面积为:>",(1/2)*math.sqrt(r**2+h**2)*2*math.pi*r+math.pi*r**2)
#     print("圆锥体积为:>",(1/3)*math.pi*r**2*h)
# else:
#     print("输入错误，请重新输入")
# str = "abcdefg"
# print("str = 'abcdefg'")
# sub = input("请输入字符串sub:>")
# x = str.find(sub)
# if x == 0:
#     print("str以sub开头")
# elif x == len(str)-len(sub):
#     print("str以sub结尾")
# else :
#     print("str既不以sub开头，也不以sub结尾")
# str="Python is a high-level, general-purpose programming language"
# #             |  |    |  |                                    | |
#    # 0123456789  12   17 20                                     59
#  # -60                                                       -3-1
# print(str[6:18])#start = 6，end = 18-1 = 17，step默认为1
# print(str[9:-3:2])#start = 9,end = -3,step = 2
# print(str[12:])#start = 12，end默认为字符串结尾，step默认为1
# print(str[-1:20:-1])#start = -1,end = 20,step = -1
# print(str[1,12,-1])#方向不同直接报错
# x = 9
# print(type(x))
# print(isinstance(x,int))#正确返回Ture,错误返回False
# y = 3.5
# print(type(y) == float)
# a = 3 + 4j#复数
# b = 5 + 6j
# print(a*b)
# print(a+b)
# print(abs(a*b))#求a*b的摸
# print(a.imag)
# print(b.imag)
# print(a.real)
# print(b.real)
# print(a.conjugate())#共轭
# print(b.conjugate())#共轭
# x = 10
# print("转化为二进制",bin(x))
# print("转化为八进制",oct(x))
# print("转化为十进制",int(x))
# print("转化为十六进制",hex(x))
# m = eval((input("请输入一个整数:>")))#排序
# sum = 0
# for i in range(1,m+1):
#     sum += i
# print("1~%d求和结果为%d"%(m,sum))
# l = []#列表输入排序
# for i in range(3):
#     x = eval(input("请输入一个整数:>"))
#     l.append(x)
# l.sort
# print(l)
# for i in range (1,10):#99乘法表
#     for j in range(1,i+1):
#         print("%d*%d=%d "%(i,j,i*j),end = '')
#     print()

#千年虫
#1
# list = [88,89,90,98,0,99]
# print("原列表:",list)
# for index in range(len(list)):
#     if list[index] != 0:
#         list[index] = "20"+str(list[index])
#     else:
#         list[index] = "200"+str(list[index])
# print(list)#上面的列表元素类型已变为字符串
#2
# list = [88,89,90,98,0,99]
# for index,item in enumerate(list):#进入循环，item = list[index]
#     if list[index] != 0:
#         list[index] = "20" + str(item)
#     else:
#         list[index] = "200" + str(item)
# print(list)

#模拟手机购物
# list = []
# for i in range(5):
#     good = input("请输入一件商品及其名称与编号：")
#     list.append(good)
# for item in list:
#     print(item)
# buy = []
# while True:
#     Flag = True
#     num = input("请输入要购买商品的编号：")
#     for item in list:
#         if num == item[0:1]:
#             Flag = False
#             buy.append(item)
#             print("商品已添加到购物车")
#             break
#     if Flag and num != 'q':
#         print("输入错误，请重新输入")
#     elif num == 'q':
#         break
# print('-'*50)
# print("您所选择的物品为：")
# print(buy)#有“”
# buy.reverse()
# for i in buy:#无“”
#     print(i)

#模拟12306购票
# dict_tickets = {"G1569":["北京南——天津南","18:06","18:39",],
#                 "G1567":["北京南——天津南","18:15","18:49"],
#                 "G8917":["北京南——天津西","18:20","19:19"],
#                 "G203":["北京南——天津南","18:35","19:09"]}
# print("车次\t\t出发站——到达站\t出发时间\t到达时间")
# for key in dict_tickets.keys():
#     print(key,end = "\t")
#     for item in dict_tickets.get(key):
#             print(item,end = "\t")
#     print()
# Num = input("请输入要购买的车次：")
# info = dict_tickets.get(Num,"车次不存在")
# if info != "车次不存在":
#     person = input("请输入乘车人，如果是多位使用逗号分开：")
#     s = info[0] + " " + info[1] + "开，请"
#     print("您购买了"+Num+" "+s+person+"尽快检票")
# else:
#     print("车次不存在")

#模拟手机通讯录
# info = set()
# for i in range(1,6):
#     item = input(f"请输入第{i}位的好友姓名与电话：")
#     info.add(item)#add,集合
# for item in info:
#     print(item)

# 判断字符串是否为四则运算表达式（不考虑括号，数字最大为99999999）
# import re#简单实现 判断字符串是否为四则运算表达式
# s = re.search("\+|-|\*|/","123-53")
# if s != None:
#     print("是四则运算表达式")
# else:
#     print("不是四则运算表达式")
# print(re.search("\+|-|\*|/","abc-de"))

#判断字符串是否为合法Python标识符（不考虑是否为关键字的情况）
# import re
# if re.match("^[a-zA-Z_][0-9a-zA-Z_]*$","6_foo") != None:
#     print("是合法Python标识符")
# else:
#     print("不是合法Python标识符")

#判断字符串是否为合法日期格式（格式为“年-月-日”，比如2002-10-01）
# import re
# import sys
# pattern = "^(\d+)-(\d{2})-(\d{2})"
# s = "2002-02-29"
# b = re.search(pattern,s)
# if b != None:
#     day = int(b.group(3))
#     month = int(b.group(2))
#     year = int(b.group(1))
#     if month<1 or month>12:
#         print("不是合法日期格式")
#         sys.exit(0)
#     if day<1 or day>31:
#         print("不是合法日期格式")
#         sys.exit(0)
#     if month in [4, 6, 9, 11]:
#         if day == 31:
#             print("不是合法日期格式")
#             sys.exit(0)
#     if month == 2:
#         if year % 400 == 0 or (year % 100 != 0 and year % 4 == 0):
#             if day <= 29:
#                 print("是合法日期格式")
#                 sys.exit(0)
#         elif day<=28:
#             print("是合法日期格式")
#             sys.exit(0)
#         else:
#             print("不是合法日期格式")
#             sys.exit(0)
#     print("是合法日期格式")
# else:
#     print("不是合法日期格式")

#请通过两种编程方法，将列表变为info=[5,4,3,2,1]
#info = [1,2,3,4,5]
#1
# info.reverse()
# print(info)
#2
# for i in range(len(info)//2):
#     tmp = info[i]
#     info[i] = info[len(info)-1-i]
#     info[len(info) - 1 - i] = tmp
# print(info)

# 已知一个列表为[1,2,3,4,1,2,3,5,2,9,6,2,3,7,8,3,4,5,2],请通过两种编程方法，去除列表中的重复项
#1
# lst = [1,2,3,4,1,2,3,5,2,9,6,2,3,7,8,3,4,5,2]
# lst = set(lst)
# lst = list(lst)
# print(lst)
#2
# lst1 = [1,2,3,4,1,2,3,5,2,9,6,2,3,7,8,3,4,5,2]
# lst2 = []
# for item in lst1:
#     if item not in lst2:
#         lst2.append(item)
#         lst2.sort()
# print(lst2)

#已知一个列表包含若干员工信息，（每个员工的信息用字典存储，键值分别为姓名（'name'）和年龄('age')）（即列表中的每一项均为一个字典对象），
#请编写一个函数，删除年龄大于60岁的员工信息
# def delete(info,count = 0):
#     """删除年龄大于60岁的员工信息"""
#     for people in info:
#         count += 1
#         for name in people.keys():
#            if (people[name])>60:
#                del info[count-1]
# info  = [{"xiaoguoping":19},{"zhangjiahui":19},{"yanzhenyun":20},{"dongjie":66}]
# delete(info)
# print(info)

#车牌归属地
# lst = ["京7666","津8666","赣9666"]
# for item in lst:
#     print(item,"归属地为：",item[0])

#统计字符串出现个数,lower、upper、capitalize、title函数,返回一个新字符串，不会改变原来的字符串

# s = "helloPython,HelloJava,HelloPhp"
# word = input("请输入要统计的字符串个数:>")
# print("%c在%s里出现%d次"%(word,s,s.upper().count(word.upper())))
# print(s.capitalize())
# print(s)

#从键盘输入两个正整数，输出这两个整数的最大公约数与  最小公倍数 = 两数相乘/最大公约数

# a,b = map(int,input("请输入2个数(用空格分开):>").split())
# tmp1 = a
# tmp2 = b
# if b == 0:
#     print("分母不能为零")
#     exit(1)
# while a % b != 0:
#     tmp3 = a
#     a = b
#     b = tmp3%b
# print("最大公约数:>%d,最小公倍数:>%d"%(b,(tmp1*tmp2/b)))

#从键盘接收一个整数，输出这个数的所有正约数

# a = int(input("请输入一个数:>"))
# for i in range(1,a+1):
#     if a % i == 0:
#         print(i,end = " ")

#求出2000-2100的所有闰年，条件是能被4整除且不能被100整除，或者能被400整除的是闰年

# for i in range(2000,2101):
#     if (i % 400 == 0) or (i % 100 != 0 and i % 4 == 0):
#         print("润年:>%d"%(i))

#求出1000以内的所有完数，如6=1+2+3  除了它自身以外的因子  (真约数)  之和等于它本身叫完数

# for i in range(1,1000):
#     sum = 0
#     for j in range(1,i):
#         if i % j == 0:
#             sum += j
#     if sum == i:
#         print("完数:>%d"%(i))

#已知一个列表包含若干员工信息，（每个员工的信息用字典存储，键值分别为姓名（'name'）和年龄('age')）（即列表中的每一项均为一个字典对象）
# 现编写一个函数，接收三个参数，第一个为列表变量，第二个参数为username，第三个参数为options，根据传入的options的值决定函数实现的功能：

#         （1）当options为1时，向列表中插入一个姓名为username，年龄为50的员工

#         （2）当options为2时，判断列表中是否有姓名为username的员工，有则返回员工的年龄，无则返回-1

#         （3）当options为3时，删除列表中姓名为username的员工

# def Func(lst,username,options):
#     if options == 1:
#         lst.append({"name":username,"age":50})
#     elif options == 2:
#         for item in lst:
#             if item["name"] == username:
#                 return item["age"]
#         return -1
#     elif options == 3:
#         for i in range(len(lst)):
#             if lst[i]["name"] == username:
#                 del lst[i]
#                 return 0
#         return -1
#
#
# lst = [{"name":"xiaoguoping","age":18},{"name":"zhangjiahui","age":19},{"name":"yanzhenyu","age":19}]
# Func(lst,"dongjie",1)#向列表中插入一个姓名为username，年龄为50的员工
# print(lst)
# Func(lst,"zhaofu",1)#向列表中插入一个姓名为username，年龄为50的员工
# print(lst)
#
# print(Func(lst,"dongjie",2))#判断列表中是否有姓名为username的员工，有则返回员工的年龄，无则返回-1
# print(Func(lst,"YC",2))#判断列表中是否有姓名为username的员工，有则返回员工的年龄，无则返回-1
#
# print(Func(lst,"dongjie",3),lst)#删除列表中姓名为username的员工,成功返回0，否则返回-1
# print(Func(lst,"gaoguanheng",3),lst)#删除列表中姓名为username的员工，成功返回0，否则返回-1

# print(format(20,"X"))#16进制输出
# print(format(20,"x"))

# lst = list(map(str, {'星期一': '吃榴莲', '星期二': '吃葡萄' , '星期三': '吃西瓜', '星期四': '吃樱桃', '星期五': '吃波罗蜜', '星期六': '吃葡萄', '星期天': '吃猕猴桃'}))
# print(lst)

# def menu():
#     print("1.添加书籍")
#     print("2.删除书籍")
#     print("3.修改书籍信息")
#     print("4.查询书籍")
#     print("5.列出所有书籍名字")
#     print("6.退出系统")
#
# def Add_Book(lst):
#     title,author,intro = map(str,input("请输入要添加的书的title,author,intro(用,隔开):>").split(','))
#     lst.append({"title":title,"author":author,"intro":intro})
#
# def Del_Book(lst):
#     Del = input("请输入要删除书的title:>")
#     for i in range(len(lst)):
#         if lst[i]["title"] == Del:
#             del lst[i]
#             return
#     print("要删除书的title不存在")
#
# def Modify_Book(lst):
#     title = input("请输入要修改的书的title:>")
#     for i in range(len(lst)):
#         if lst[i]["title"] == title:
#             title,author,intro = map(str,input("请输入修改后的书的title,author,intro(用,隔开):>").split(','))
#             lst[i] = {"title":title,"author":author,"intro":intro}
#             return
#     print("要修改的书的title不存在")
#
# def Check_Book(lst):
#     title = input("请输入要查询的书的title:>")
#     for item in lst:
#         if item["title"] == title:
#             print("tltle:%s author:%s intro:%s"%(item["title"],item["author"],item["intro"]))
#             return
#     print("要查询的书的title不存在")
#
# def Show_Book(lst):
#     print("name", end=":>")
#     for item in lst:
#         print("%s"%(item["title"]),end = " ")
#     print()
#
# lst = [{"title":"19","author":"yusiye","intro":"love"},{"title":"20","author":"L","intro":"you"}]
#
# while True:
#     menu()
#     option = (int)(input("请输入您的选项:>"))
#     if option == 1:
#         Add_Book(lst)
#     elif option == 2:
#         Del_Book(lst)
#     elif option == 3:
#         Modify_Book(lst)
#     elif option == 4:
#         Check_Book(lst)
#     elif option == 5:
#         Show_Book(lst)
#     elif option == 6:
#         print("退出成功!")
#         break

# #多态
# class Cat:#没有父类时，可省略 创建类时 后面的()
#     def eat(self):
#         print("猫，喜欢吃鱼")
#
# class Dog():
#     def eat(self):
#         print("狗，喜欢吃骨头")
#
# def Fun(s):
#     s.eat()
#
# cat = Cat()#对象名 = 类名()
# dog = Dog()
#
# Fun(cat)
# Fun(dog)

# #计算圆的面积和周长
# import math
# class Circle:
#     def __init__(self,r):
#         self.r = r
#     def get_area(self):
#         return math.pi*self.r**2
#     def get_perimeter(self):
#         return 2*math.pi*self.r
# r = int(input("请输入圆的半径:>"))
# c = Circle(r)
# print("圆的面积为:>",c.get_area())
# print("圆的周长为:>",c.get_perimeter())

# #定义学生类，输入3个学生信息，将类存储到列表中
# class Student:
#     def __init__(self,name,age,gender):
#         self.name = name
#         self.age = age
#         self.gender = gender
#     def Info(self):
#         print(self.name,self.age,self.gender)
#
# stu_list = []
# for item in range(1,4):
#     stuinfo = input("请输入学生姓名，年龄，性别(用#分隔)").split('#')
#     stu = Student(stuinfo[0],stuinfo[1],stuinfo[2])
#     stu_list.append(stu)
# for item in stu_list:
#     item.Info()

# #面向对象思想实现乐器弹奏
# class Instrument:
#     def Make_Sound(self):
#         pass
#
# class Erhu(Instrument):
#     def Make_Sound(self):
#         print("二胡在弹奏")
#
# class Piano(Instrument):
#     def Make_Sound(self):
#         print("钢琴在弹奏")
#
# class Violin(Instrument):
#     def Make_Sound(self):
#         print("小提琴在弹奏")
#
#
# def Play(obj):
#     obj.Make_Sound()
#
# Erhu = Erhu()
# Piano = Piano()
# Violin = Violin()
#
# Play(Erhu)
# Play(Piano)
# Play(Violin)

# #面向对象思想_出租车类和家用轿车类
# class car:
#     def __init__(self,type,no):
#         self.type = type
#         self.no = no
#     def start(self):
#         print("我是车，已启动")
#     def end(self):
#         print("我是车，已停止")
#
# class taxi(car):
#     def __init__(self,type,no,company):
#         super().__init__(type,no)
#         self.company = company
#     def start(self):
#         print("乘客您好")
#         print(f"我是{self.company}公司的，车牌号为{self.no}")
#         print("请系好您的安全带")
#     def end(self):
#         print("您的目的地已到达")
#
# class family_car(car):
#     def __init__(self, type, no, name):
#         super().__init__(type, no)
#         self.name = name
#     def start(self):
#
#         print(f"我是{self.name},车牌号为{self.no},我的车我做主")
#     def end(self):
#         print("目的地已到达")
#
# taxi = taxi("本田","888","日本")
# taxi.start()
# taxi.end()
# print('-'*40)
# family_car = family_car("雅阁","666","Lzc")
# family_car.start()
# family_car.end()






















